# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=webhandler
pkgver=348.1bd971e
pkgrel=3
groups=('blackarch' 'blackarch-webapp')
pkgdesc="A handler for PHP system functions & also an alternative 'netcat' handler."
url='https://github.com/lnxg33k/webhandler'
license=('custom:unknown')
arch=('any')
depends=('python2')
makedepends=('git')
source=('git+https://github.com/lnxg33k/webhandler.git')
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec python2 /usr/share/$pkgname/$pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

